
	// 17900043 唐国橼
	//正在热映的电影
	$(".navbar-brand").click(function() {
		$.ajax({
			method: "get",
			url: "https://douban.uieee.com/v2/movie/in_theaters",
			dataType: "jsonp",
			success: function(r) {
				var s = $("<span></span>");
				for (let i = 1; i <= 6; i++) {
					let j = i - 1;
					var sc = s.clone();
					sc.attr("id", i + "span");
					$(".row .text-danger").eq(i - 1).prepend(sc.html(r.subjects[j].title));
					var imgs = $("<img src=" + r.subjects[j].images.small + ">");
					$(".col-md-6:nth-child(" + i + ") >.media").prepend(imgs);

					var str1 = `上映时间:${r.subjects[j].pubdates[0]}<br>`;
					var str2 = `时长:${r.subjects[j].durations}<br>`;
					var str3 = `类型:${r.subjects[j].genres[0]}<br>`;
					var str4 = `主演人员:${r.subjects[j].casts[0].name}<br>`;

					$(".text-muted").eq(i - 1).html(str1 + str2 + str3 + str4);
					$(".spinner-border").remove();
				}
			},
			beforeSend: function() {
				var loading =
					`<div class="spinner-border text-primary" role="status">
  <span class="sr-only">Loading...</span>
</div>`;
				$(".n").append(loading);
			}
		});
	});

	//即将上映的电影
	$("#abc1").click(function() {
		$.ajax({
			method: "get",
			url: "https://douban.uieee.com/v2/movie/coming_soon",
			dataType: "jsonp",
			success: function(r) {
				var s = $("<span></span>");
				for (let i = 1; i <= 6; i++) {
					let j = i - 1;
					var sc = s.clone();
					sc.attr("id", i + "span");
					$(".row .text-danger").eq(i - 1).prepend(sc.html(r.subjects[j].title));
					var imgs = $("<img src=" + r.subjects[j].images.small + ">");
					$(".col-md-6:nth-child(" + i + ") >.media").prepend(imgs);					
					if (r.subjects[j].casts[0] == null) {
						r.subjects[j].casts[0] = {
							name: "未知"
						};
					}
					var str1 = `上映时间:${r.subjects[j].pubdates[0]}<br>`;
					var str2 = `时长:${r.subjects[j].durations}<br>`;
					var str3 = `类型:${r.subjects[j].genres[0]}<br>`;
					var str4 = `主演人员:${r.subjects[j].casts[0].name}<br>`;

					$(".text-muted").eq(i - 1).html(str1 + str2 + str3 + str4);
					$(".spinner-border").remove();
				}
			},
			beforeSend: function() {
				var loading =
					`<div class="spinner-border text-primary" role="status">
	  <span class="sr-only">Loading...</span>
	</div>`;
				$("#abc1").append(loading);
			}
		});
	});	

//电影top榜
	$("#abc2").click(function() {
		$.ajax({
			method: "get",
			url: "https://douban.uieee.com/v2/movie/top250",
			dataType: "jsonp",
			success: function(e) {
				var s = $("<span></span>");
				for (let i = 1; i <= 6; i++) {
					let j = i - 1;
					var sc = s.clone();
					sc.attr("id", i + "span");
					$(".row .text-danger").eq(i - 1).prepend(sc.html(e.subjects[j].title));
					var imgs = $("<img src=" + e.subjects[j].images.small + ">");
					$(".col-md-6:nth-child(" + i + ") >.media").prepend(imgs);					
					if (e.subjects[j].casts[0] == null) {
						e.subjects[j].casts[0] = {
							name: "未知"
						};
					}
					var str1 = `上映时间:${e.subjects[j].pubdates[0]}<br>`;
					var str2 = `时长:${e.subjects[j].durations}<br>`;
					var str3 = `类型:${e.subjects[j].genres[0]}<br>`;
					var str4 = `主演人员:${e.subjects[j].casts[0].name}<br>`;
	
					$(".text-muted").eq(i - 1).html(str1 + str2 + str3 + str4);
					$(".spinner-border").remove();
				}
			},
			beforeSend: function() {
				var loading =
					`<div class="spinner-border text-primary" role="status">
	  <span class="sr-only">Loading...</span>
	</div>`;
				$("#abc2").append(loading);
			}
		});
	});
